package it.marcomondini.proximitytools.powermanagement;

import it.marcomondini.proximitytools.MyApplication;
import android.content.Context;
import android.os.PowerManager;

public class WakeRunner {

	private static final PowerManager pm = (PowerManager) MyApplication.getInstance().getSystemService(Context.POWER_SERVICE);

	public static void acquireCpuWakeLock(int flags, WakeFragment wul ) {
		
		PowerManager.WakeLock sCpuWakeLock = pm.newWakeLock(flags, wul.getClass().toString());
		
		try {
			sCpuWakeLock.acquire();
			wul.wakeRun();
		} finally{
			sCpuWakeLock.release();
		}

	}
	
}
